﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for D_UserPurchase
/// </summary>
/// 
namespace Bestlife.ERP.DataAccess {
    public class D_UserPurchase
    {
        public D_UserPurchase()
        {
            //
            // TODO: Add constructor logic here
            //
        }

         public Boolean UserPurchase_Add(Entities.E_UserPurchs Epches) 
        {
            bool userpurchase = false;

            try
            {
                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);

                String insertpurchase = "INSERT INTO Tbl_UserPurchase(Use_ID,Pro_ID,Code,Qty,Price,PV,BV,User_Create,Date_Create,Last_Modify,Key_Timestamp)VALUES('" + Epches.User_ID + "','" + Epches.ProID + "','" + Epches.Code + "','" + Epches.Qty + "','" + Epches.Price + "','" + Epches.PV + "','" + Epches.BV + "','" + Epches.User_Create + "','" + Epches.Date_Create + "','" + Epches.Last_modify + "','" + Epches.Key_Timestamp + "')";
                userpurchase = Bestlife.ERP.DataAccess.clsCon.AddEditDel(insertpurchase);

               
            }
            catch (Exception ex) { }

            return userpurchase;
        }

         # region Update userpurchase

         public void Update_Userpurchase(Entities.E_UserPurchs upches)
         {


             try
             {

                 String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                 Bestlife.ERP.DataAccess.clsCon.connect(connStr);
                 //String insertpurchase = "INSERT INTO Tbl_UserPurchase(Use_ID,Pro_ID,Code,Qty,Price,PV,BV,Bv,User_Create,Date_Create,Last_Modifty,Key_Timestarmp)VALUES('" + Epches.User_ID + "','" + Epches.ProID + "','" + Epches.Code + "','" + Epches.Qty + "','" + Epches.Price + "','" + Epches.PV + "','" + Epches.BV + "','" + Epches.User_Create + "','" + Epches.Date_Create + "')";

                 //SqlCommand act = new SqlCommand("UPDATE Bonus SET Tpv='" + totPV + "',ppv='" + totPV + "',T_sales='" + totPrice + "',Bv='" + totBV + "',Tbv='" + totBV + "' WHERE User_id='" + uid + "'", clsCon.conn_new);
                 //act.ExecuteNonQuery();

                 // DataAccess.calculations cal = new calculations();

                 // cal.calculationss(uid, totBV, totPV, totPrice);


                 DataAccess.calculation_Daily cald = new calculation_Daily();
                 //cald.calculation_Dailys(uid, totBV, totPV, totPrice);//comment temp-----




             }
             catch (Exception err)
             {
                 //Response.Redirect("404.aspx?Massage=" + err.Message.ToString());
             }
             finally
             {
                 clsCon.conn_new.Close();
             }

         }



         #endregion
   
    }
}